Next function is executed more than 3 hours(for 24GB english-ASCII-texts) for pattern:

*requests???????????into*

on AMD Barton 2600+(1920MHz).

 

0101 // -----------------------------------------

0102 // this function tests is name matches mask

0103 // ? - any wchar_t or empty                 

0104 // * - any characters or empty

0105 static bool EnhancedMaskTest_OrEmpty(const char *mask, int maskPos,

0106                                      const char *name, int namePos)

0107 {

0108   char maskChar;

0109   int maskLen = KAZE_strlen(mask) - maskPos;

0110   int nameLen = KAZE_strlenLF(name) - namePos;

0111   if (maskLen == 0)

0112     if (nameLen == 0)

0113       return true;

0114     else

0115       return false;

0116   maskChar = mask[maskPos];

0117   if (maskChar == '?')

0118   {

0119     /*

0120     if (EnhancedMaskTest_OrEmpty(mask, maskPos + 1, name, namePos))

0121       return true;

0122     */

0123     if (EnhancedMaskTest_OrEmpty(mask, maskPos + 1, name, namePos)) // KAZE: THIS LINE DECIDES whether 'or empty' or 'and not empty'

0124       return true;                                                  //       uncommented is 'or empty'

0125     if (nameLen == 0)

0126       return false;

0127     return EnhancedMaskTest_OrEmpty(mask,  maskPos + 1, name, namePos + 1);

0128   }

0129   else if(maskChar == '*')

0130   {

0131     if (EnhancedMaskTest_OrEmpty(mask, maskPos + 1, name, namePos))

0132       return true;

0133     if (nameLen == 0)

0134       return false;

0135     return EnhancedMaskTest_OrEmpty(mask, maskPos, name, namePos + 1);

0136   }

0137   else

0138   {

0139     char c = name[namePos];

0140     //if (maskChar != c)

0141       if (KAZE_toupper(maskChar) != KAZE_toupper(c))

0142         return false;

0143     return EnhancedMaskTest_OrEmpty(mask,  maskPos + 1, name, namePos + 1);

0144   }

0145 }

 

; Function compile flags: /Ogty

tv294 = -4                            ; size = 4

_mask$ = 8                            ; size = 4

_maskPos$ = 12                        ; size = 4

_name$ = 16                           ; size = 4

_namePos$ = 20                        ; size = 4

_EnhancedMaskTest_OrEmpty PROC NEAR

; Line 107

     push ecx

; Line 109

     mov  eax, DWORD PTR _maskPos$[esp]

     push ebx

     mov  ebx, DWORD PTR _mask$[esp+4]

     push ebp

     mov  ebp, DWORD PTR _name$[esp+8]

     push esi

     mov  esi, DWORD PTR _namePos$[esp+12]

     push edi

$L3196:

     inc  eax

     mov  DWORD PTR tv294[esp+20], eax

     npad 6

$L3185:

     mov  eax, ebx

$L3176:

     mov  cl, BYTE PTR [eax]

     inc  eax

     test cl, cl

     jne  SHORT $L3176

     mov  edx, DWORD PTR _maskPos$[esp+16]

     sub  eax, ebx

     sub  eax, edx

     dec  eax

     mov  ecx, eax

; Line 110

     mov  eax, ebp

$L3183:

     mov  dl, BYTE PTR [eax]

     inc  eax

     cmp  dl, 10                       ; 0000000aH

     jne  SHORT $L3183

     sub  eax, ebp

     sub  eax, esi

     dec  eax

; Line 111

     test ecx, ecx

     mov  edi, eax

     je   $L3190

; Line 116

     mov  eax, DWORD PTR _maskPos$[esp+16]

     mov  al, BYTE PTR [ebx+eax]

; Line 117

     cmp  al, 63                       ; 0000003fH

     jne  SHORT $L592

; Line 123

     mov  ecx, DWORD PTR tv294[esp+20]

     push esi

     push ebp

     push ecx

     push ebx

     call _EnhancedMaskTest_OrEmpty

     add  esp, 16                      ; 00000010H

     test ax, ax

     jne  $L3191

; Line 125

     test edi, edi

     je   $L3195

; Line 127

     mov  ecx, DWORD PTR _maskPos$[esp+16]

     mov  eax, DWORD PTR tv294[esp+20]

     inc  esi

     inc  ecx

     mov  DWORD PTR _maskPos$[esp+16], ecx

     jmp  SHORT $L3196

$L592:

; Line 129

     cmp  al, 42                       ; 0000002aH

     jne  SHORT $L596

; Line 131

     mov  edx, DWORD PTR tv294[esp+20]

     push esi

     push ebp

     push edx

     push ebx

     call _EnhancedMaskTest_OrEmpty

     add  esp, 16                      ; 00000010H

     test ax, ax

     jne  SHORT $L3191

; Line 133

     test edi, edi

     je   SHORT $L3195

; Line 135

     inc  esi

     jmp  $L3185

$L596:

; Line 141

     cmp  al, 97                       ; 00000061H

     mov  cl, BYTE PTR [esi+ebp]

     jl   SHORT $L3168

     cmp  al, 122                      ; 0000007aH

     jg   SHORT $L3168

     movsx     edx, al

     sub  edx, 32                      ; 00000020H

     jmp  SHORT $L3169

$L3168:

     movsx     edx, al

$L3169:

     cmp  cl, 97                       ; 00000061H

     jl   SHORT $L3170

     cmp  cl, 122                      ; 0000007aH

     jg   SHORT $L3170

     movsx     eax, cl

     sub  eax, 32                      ; 00000020H

     jmp  SHORT $L3171

$L3170:

     movsx     eax, cl

$L3171:

     cmp  edx, eax

     jne  SHORT $L3195

; Line 143

     mov  ecx, DWORD PTR _maskPos$[esp+16]

     mov  eax, DWORD PTR tv294[esp+20]

     inc  esi

     inc  ecx

     mov  DWORD PTR _maskPos$[esp+16], ecx

     jmp  $L3196

$L3190:

; Line 112

     xor  eax, eax

     test edi, edi

     pop  edi

     pop  esi

     pop  ebp

     sete al

     pop  ebx

; Line 145

     pop  ecx

     ret  0

$L3191:

     pop  edi

     pop  esi

     pop  ebp

; Line 124

     mov  ax, 1

     pop  ebx

; Line 145

     pop  ecx

     ret  0

$L3195:

     pop  edi

     pop  esi

     pop  ebp

; Line 142

     xor  ax, ax

     pop  ebx

; Line 145

     pop  ecx

     ret  0

_EnhancedMaskTest_OrEmpty ENDP